{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import tensorflow as tf\n",
    "import xlrd\n",
    "import os\n",
    "from sklearn.utils import check_random_state"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Generating artificial data.\n",
    "n = 50\n",
    "XX = np.arange(n)\n",
    "rs = check_random_state(0)\n",
    "YY = rs.randint(-10, 10, size=(n,)) + 2.0 * XX\n",
    "data = np.stack([XX,YY], axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#######################\n",
    "## Defining flags #####\n",
    "#######################\n",
    "\n",
    "num_epochs = 50"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# creating the weight and bias.\n",
    "# The defined variables will be initialized to zero.\n",
    "W = tf.Variable(0.0, name=\"weights\")\n",
    "b = tf.Variable(0.0, name=\"bias\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "###############################\n",
    "##### Necessary functions #####\n",
    "###############################\n",
    "\n",
    "#  Creating placeholders for input X and label Y.\n",
    "def inputs():\n",
    "    \"\"\"\n",
    "    Defining the place_holders.\n",
    "    :return:\n",
    "            Returning the data and label place holders.\n",
    "    \"\"\"\n",
    "    X = tf.placeholder(tf.float32, name=\"X\")\n",
    "    Y = tf.placeholder(tf.float32, name=\"Y\")\n",
    "    return X,Y\n",
    "\n",
    "# Create the prediction.\n",
    "def inference(X):\n",
    "    \"\"\"\n",
    "    Forward passing the X.\n",
    "    :param X: Input.\n",
    "    :return: X*W + b.\n",
    "    \"\"\"\n",
    "    return X * W + b\n",
    "\n",
    "def loss(X, Y):\n",
    "    '''\n",
    "    compute the loss by comparing the predicted value to the actual label.\n",
    "    :param X: The input.\n",
    "    :param Y: The label.\n",
    "    :return: The loss over the samples.\n",
    "    '''\n",
    "\n",
    "    # Making the prediction.\n",
    "    Y_predicted = inference(X)\n",
    "    return tf.reduce_sum(tf.squared_difference(Y, Y_predicted))/(2*data.shape[0])\n",
    "\n",
    "\n",
    "# The training function.\n",
    "def train(loss):\n",
    "    learning_rate = 0.0001\n",
    "    return tf.train.GradientDescentOptimizer(learning_rate).minimize(loss)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "epoch 1, loss=1573.599976\n",
      "epoch 2, loss=1332.513916\n",
      "epoch 3, loss=1128.868408\n",
      "epoch 4, loss=956.848999\n",
      "epoch 5, loss=811.544067\n",
      "epoch 6, loss=688.804993\n",
      "epoch 7, loss=585.127441\n",
      "epoch 8, loss=497.550781\n",
      "epoch 9, loss=423.574799\n",
      "epoch 10, loss=361.087372\n",
      "epoch 11, loss=308.304138\n",
      "epoch 12, loss=263.718170\n",
      "epoch 13, loss=226.056366\n",
      "epoch 14, loss=194.243423\n",
      "epoch 15, loss=167.371048\n",
      "epoch 16, loss=144.671936\n",
      "epoch 17, loss=125.497986\n",
      "epoch 18, loss=109.301781\n",
      "epoch 19, loss=95.620842\n",
      "epoch 20, loss=84.064514\n",
      "epoch 21, loss=74.302887\n",
      "epoch 22, loss=66.057228\n",
      "epoch 23, loss=59.092148\n",
      "epoch 24, loss=53.208710\n",
      "epoch 25, loss=48.238998\n",
      "epoch 26, loss=44.041073\n",
      "epoch 27, loss=40.495071\n",
      "epoch 28, loss=37.499771\n",
      "epoch 29, loss=34.969639\n",
      "epoch 30, loss=32.832432\n",
      "epoch 31, loss=31.027143\n",
      "epoch 32, loss=29.502199\n",
      "epoch 33, loss=28.214087\n",
      "epoch 34, loss=27.126015\n",
      "epoch 35, loss=26.206921\n",
      "epoch 36, loss=25.430567\n",
      "epoch 37, loss=24.774773\n",
      "epoch 38, loss=24.220827\n",
      "epoch 39, loss=23.752905\n",
      "epoch 40, loss=23.357647\n",
      "epoch 41, loss=23.023775\n",
      "epoch 42, loss=22.741753\n",
      "epoch 43, loss=22.503529\n",
      "epoch 44, loss=22.302298\n",
      "epoch 45, loss=22.132318\n",
      "epoch 46, loss=21.988735\n",
      "epoch 47, loss=21.867451\n",
      "epoch 48, loss=21.764999\n",
      "epoch 49, loss=21.678465\n",
      "epoch 50, loss=21.605358\n"
     ]
    }
   ],
   "source": [
    "with tf.Session() as sess:\n",
    "\n",
    "    # Initialize the variables[w and b].\n",
    "    sess.run(tf.global_variables_initializer())\n",
    "\n",
    "    # Get the input tensors\n",
    "    X, Y = inputs()\n",
    "\n",
    "    # Return the train loss and create the train_op.\n",
    "    train_loss = loss(X, Y)\n",
    "    train_op = train(train_loss)\n",
    "\n",
    "    # Step 8: train the model\n",
    "    for epoch_num in range(num_epochs):\n",
    "        loss_value, _ = sess.run([train_loss,train_op],\n",
    "                                 feed_dict={X: data[:,0], Y: data[:,1]})\n",
    "\n",
    "        # Displaying the loss per epoch.\n",
    "        print('epoch %d, loss=%f' %(epoch_num+1, loss_value))\n",
    "\n",
    "        # save the values of weight and bias\n",
    "        wcoeff, bias = sess.run([W, b])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xd4VNXWwOHfDiWhl9AJIfQAoYUiRanS+xUbUUFRvJYL\nliuigHTFhuK1fMYGKrarlKB0EAW8VEFJg0RIIJSElhDSSDL7+2MGBUyZmZzJtPU+j89kTk7ZJw4r\nK/vsvbbSWiOEEML9+Ti7AUIIIYwhAV0IITyEBHQhhPAQEtCFEMJDSEAX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q2+01vOUUk0xZ641gQPAPVrrHOe11HEsXS7/1lqP8PT7ttzfSsvbssAXWuuF\nSil/DPqcu0VAF0IIUTx36HIRQghhBQnoQgjhISSgCyGEh5CALoQQHkICuhBCeAgJ6EII4SEkoAsh\nhIeQgC6EEB7i/wG9mz9kj6oOnAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x11cd7c358>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "###############################\n",
    "#### Evaluate and plot ########\n",
    "###############################\n",
    "Input_values = data[:,0]\n",
    "Labels = data[:,1]\n",
    "Prediction_values = data[:,0] * wcoeff + bias\n",
    "\n",
    "# uncomment if plotting is desired!\n",
    "plt.plot(Input_values, Labels, 'ro', label='main')\n",
    "plt.plot(Input_values, Prediction_values, label='Predicted')\n",
    "\n",
    "# Saving the result.\n",
    "plt.legend()\n",
    "plt.show()\n",
    "plt.close()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
